<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquicktaphandler.cpp -->
  <title>TapHandler QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >TapHandler QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#signals">信号</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">TapHandler QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$TapHandler-brief -->
<p>Handler for taps and clicks. <a href="#details">更多...</a></p>
<!-- @@@TapHandler -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-singlepointhandler.html">SinglePointHandler</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-taphandler-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#acceptedButtons-prop">acceptedButtons</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#acceptedDevices-prop">acceptedDevices</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#acceptedModifiers-prop">acceptedModifiers</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#acceptedPointerTypes-prop">acceptedPointerTypes</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#active-prop">active</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#enabled-prop">enabled</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#gesturePolicy-prop">gesturePolicy</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#grabPermissions-prop">grabPermissions</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#longPressThreshold-prop">longPressThreshold</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#margin-prop">margin</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#parent-prop">parent</a></b></b> : Item</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#point-prop">point</a></b></b> : HandlerPoint</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#pressed-prop">pressed</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#tapCount-prop">tapCount</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#target-prop">target</a></b></b> : Item</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#timeHeld-prop">timeHeld</a></b></b> : real</li>
</ul>
<a name="signals"></a>
<h2 id="signals">信号</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#canceled-signal">canceled</a></b></b>(EventPoint <i>point</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#doubleTapped-signal">doubleTapped</a></b></b>()</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#grabChanged-signal">grabChanged</a></b></b>(GrabTransition <i>transition</i>,  EventPoint <i>point</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#longPressed-signal">longPressed</a></b></b>()</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#singleTapped-signal">singleTapped</a></b></b>()</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#tapCountChanged-signal">tapCountChanged</a></b></b>()</li>
<li class="fn"><b><b><a href="qml-qtquick-taphandler.html#tapped-signal">tapped</a></b></b>()</li>
</ul>
<!-- $$$TapHandler-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p><a href="qml-qtquick-taphandler.html">TapHandler</a> is a handler for taps on a touchscreen or clicks on a mouse.</p>
<p>Detection of a valid tap gesture depends on <a href="qml-qtquick-taphandler.html#gesturePolicy-prop">gesturePolicy</a>. The default value is DragThreshold, which requires the press and release to be close together in both space and time. In this case, <a href="qml-qtquick-draghandler.html">DragHandler</a> is able to function using only a passive grab, and therefore does not interfere with event delivery to any other Items or Input Handlers. So the default <a href="qml-qtquick-taphandler.html#gesturePolicy-prop">gesturePolicy</a> is useful when you want to modify behavior of an existing control or Item by adding a <a href="qml-qtquick-taphandler.html">TapHandler</a> with bindings and/or JavaScript callbacks.</p>
<p>Note that buttons (such as <a href="../qtwidgets/qpushbutton.html">QPushButton</a>) are often implemented not to care whether the press and release occur close together: if you press the button and then change your mind, you need to drag all the way off the edge of the button in order to cancel the click. For this use case, set the <a href="qml-qtquick-taphandler.html#gesturePolicy-prop">gesturePolicy</a> to <code>TapHandler.ReleaseWithinBounds</code>.</p>
<p>For multi-tap gestures (double-tap, triple-tap etc.), the distance moved must not exceed <a href="../qtgui/qplatformtheme.html#ThemeHint-enum">QPlatformTheme::MouseDoubleClickDistance</a> with mouse and <a href="../qtgui/qplatformtheme.html#ThemeHint-enum">QPlatformTheme::TouchDoubleTapDistance</a> with touch, and the time between taps must not exceed <a href="../qtgui/qstylehints.html#mouseDoubleClickInterval-prop">QStyleHints::mouseDoubleClickInterval()</a>.</p>
<p><b>请参考 </b><a href="qml-qtquick-mousearea.html">MouseArea</a>。</p>
<!-- @@@TapHandler -->
<h2>属性文档</h2>
<!-- $$$acceptedButtons -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedButtons-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedButtons-prop"></a><span class="name">acceptedButtons</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The mouse buttons which can activate this Pointer Handler.</p>
<p>By default, this property is set to <a href="qml-qtquick-mouseevent.html#button-prop">Qt.LeftButton</a>. It can be set to an OR combination of mouse buttons, and will ignore events from other buttons.</p>
<p>For example, a control could be made to respond to left and right clicks in different ways, with two handlers:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
          <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;left clicked&quot;</span>)
      }
      <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
          <span class="name">acceptedButtons</span>: <span class="name">Qt</span>.<span class="name">RightButton</span>
          <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;right clicked&quot;</span>)
      }
  }

</pre>
<p><b>Note: </b>Tapping on a touchscreen or tapping the stylus on a graphics tablet emulates clicking the left mouse button. This behavior can be altered via <a href="qml-qtquick-taphandler.html#acceptedDevices-prop">acceptedDevices</a> or <a href="qml-qtquick-taphandler.html#acceptedPointerTypes-prop">acceptedPointerTypes</a>.</p></div></div><!-- @@@acceptedButtons -->
<br/>
<!-- $$$acceptedDevices -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedDevices-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedDevices-prop"></a><span class="name">acceptedDevices</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The types of pointing devices that can activate this Pointer Handler.</p>
<p>By default, this property is set to <a href="qml-qtquick-pointerdevice.html#type-prop">PointerDevice.AllDevices</a>. If you set it to an OR combination of device types, it will ignore events from non-matching devices.</p>
<p>For example, a control could be made to respond to mouse and stylus clicks in one way, and touchscreen taps in another way, with two handlers:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedDevices</span>: <span class="name">PointerDevice</span>.<span class="name">Mouse</span> <span class="operator">|</span> <span class="name">PointerDevice</span>.<span class="name">Stylus</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;clicked&quot;</span>)
     }
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedDevices</span>: <span class="name">PointerDevice</span>.<span class="name">TouchScreen</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;tapped&quot;</span>)
     }
  }

</pre>
</div></div><!-- @@@acceptedDevices -->
<br/>
<!-- $$$acceptedModifiers -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedModifiers-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedModifiers-prop"></a><span class="name">acceptedModifiers</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this property is set, it will require the given keyboard modifiers to be pressed in order to react to pointer events, and otherwise ignore them.</p>
<p>If this property is set to <code>Qt.KeyboardModifierMask</code> (the default value), then the <a href="qml-qtquick-pointerhandler.html">PointerHandler</a> ignores the modifier keys.</p>
<p>For example, an <a href="qml-qtquick-item.html">Item</a> could have two handlers of the same type, one of which is enabled only if the required keyboard modifiers are pressed:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedModifiers</span>: <span class="name">Qt</span>.<span class="name">ControlModifier</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;control-tapped&quot;</span>)
     }
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedModifiers</span>: <span class="name">Qt</span>.<span class="name">NoModifier</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;tapped&quot;</span>)
     }
  }

</pre>
</div></div><!-- @@@acceptedModifiers -->
<br/>
<!-- $$$acceptedPointerTypes -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedPointerTypes-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedPointerTypes-prop"></a><span class="name">acceptedPointerTypes</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The types of pointing instruments (finger, stylus, eraser, etc.) that can activate this Pointer Handler.</p>
<p>By default, this property is set to <a href="qml-qtquick-pointerdevice.html#pointerType-prop">PointerDevice.AllPointerTypes</a>. If you set it to an OR combination of device types, it will ignore events from non-matching events.</p>
<p>For example, a control could be made to respond to mouse, touch, and stylus clicks in some way, but delete itself if tapped with an eraser tool on a graphics tablet, with two handlers:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
     <span class="name">id</span>: <span class="name">rect</span>
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedPointerTypes</span>: <span class="name">PointerDevice</span>.<span class="name">GenericPointer</span> <span class="operator">|</span> <span class="name">PointerDevice</span>.<span class="name">Finger</span> <span class="operator">|</span> <span class="name">PointerDevice</span>.<span class="name">Pen</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;clicked&quot;</span>)
     }
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedPointerTypes</span>: <span class="name">PointerDevice</span>.<span class="name">Eraser</span>
         <span class="name">onTapped</span>: <span class="name">rect</span>.<span class="name">destroy</span>()
     }
  }

</pre>
</div></div><!-- @@@acceptedPointerTypes -->
<br/>
<!-- $$$active -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="active-prop">
<td class="tblQmlPropNode"><p>
<a name="active-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">active</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This holds true whenever this Input Handler has taken sole responsibility for handing one or more EventPoints, by successfully taking an exclusive grab of those points. This means that it is keeping its properties up-to-date according to the movements of those Event Points and actively manipulating its <a href="qml-qtquick-taphandler.html#target-prop">target</a> (if any).</p>
</div></div><!-- @@@active -->
<br/>
<!-- $$$enabled -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="enabled-prop">
<td class="tblQmlPropNode"><p>
<a name="enabled-prop"></a><span class="name">enabled</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If a <a href="qml-qtquick-pointerhandler.html">PointerHandler</a> is disabled, it will reject all events and no signals will be emitted.</p>
</div></div><!-- @@@enabled -->
<br/>
<!-- $$$gesturePolicy -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="gesturePolicy-prop">
<td class="tblQmlPropNode"><p>
<a name="gesturePolicy-prop"></a><span class="name">gesturePolicy</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The spatial constraint for a tap or long press gesture to be recognized, in addition to the constraint that the release must occur before <a href="qml-qtquick-taphandler.html#longPressThreshold-prop">longPressThreshold</a> has elapsed. If these constraints are not satisfied, the <a href="qml-qtquick-taphandler.html#tapped-signal">tapped</a> signal is not emitted, and <a href="qml-qtquick-taphandler.html#tapCount-prop">tapCount</a> is not incremented. If the spatial constraint is violated, <a href="qml-qtquick-taphandler.html#pressed-prop">pressed</a> transitions immediately from true to false, regardless of the time held.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>TapHandler.DragThreshold</code></td><td class="topAlign">(the default value) The event point must not move significantly. If the mouse, finger or stylus moves past the system-wide drag threshold (<a href="../qtgui/qstylehints.html#startDragDistance-prop">QStyleHints::startDragDistance</a>), the tap gesture is canceled, even if the button or finger is still pressed. This policy can be useful whenever <a href="qml-qtquick-taphandler.html">TapHandler</a> needs to cooperate with other input handlers (for example <a href="qml-qtquick-draghandler.html">DragHandler</a>) or event-handling Items (for example <a href="qtquick-module.html">QtQuick</a> Controls), because in this case <a href="qml-qtquick-taphandler.html">TapHandler</a> will not take the exclusive grab, but merely a passive grab.</td></tr>
<tr><td class="topAlign"><code>TapHandler.WithinBounds</code></td><td class="topAlign">If the event point leaves the bounds of the <code>parent</code> Item, the tap gesture is canceled. The <a href="qml-qtquick-taphandler.html">TapHandler</a> will take the exclusive grab on press, but will release the grab as soon as the boundary constraint is no longer satisfied.</td></tr>
<tr><td class="topAlign"><code>TapHandler.ReleaseWithinBounds</code></td><td class="topAlign">At the time of release (the mouse button is released or the finger is lifted), if the event point is outside the bounds of the <code>parent</code> Item, a tap gesture is not recognized. This corresponds to typical behavior for button widgets: you can cancel a click by dragging outside the button, and you can also change your mind by dragging back inside the button before release. Note that it's necessary for <a href="qml-qtquick-taphandler.html">TapHandler</a> take the exclusive grab on press and retain it until release in order to detect this gesture.</td></tr>
</table></div>
</div></div><!-- @@@gesturePolicy -->
<br/>
<!-- $$$grabPermissions -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="grabPermissions-prop">
<td class="tblQmlPropNode"><p>
<a name="grabPermissions-prop"></a><span class="name">grabPermissions</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property specifies the permissions when this handler's logic decides to take over the exclusive grab, or when it is asked to approve grab takeover or cancellation by another handler.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>PointerHandler.TakeOverForbidden</code></td><td class="topAlign">This handler neither takes from nor gives grab permission to any type of Item or Handler.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.CanTakeOverFromHandlersOfSameType</code></td><td class="topAlign">This handler can take the exclusive grab from another handler of the same class.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.CanTakeOverFromHandlersOfDifferentType</code></td><td class="topAlign">This handler can take the exclusive grab from any kind of handler.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.CanTakeOverFromAnything</code></td><td class="topAlign">This handler can take the exclusive grab from any type of Item or Handler.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByHandlersOfSameType</code></td><td class="topAlign">This handler gives permission for another handler of the same class to take the grab.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByHandlersOfDifferentType</code></td><td class="topAlign">This handler gives permission for any kind of handler to take the grab.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByItems</code></td><td class="topAlign">This handler gives permission for any kind of Item to take the grab.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesCancellation</code></td><td class="topAlign">This handler will allow its grab to be set to null.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByAnything</code></td><td class="topAlign">This handler gives permission for any any type of Item or Handler to take the grab.</td></tr>
</table></div>
<p>The default is <code>PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType | PointerHandler.ApprovesTakeOverByAnything</code> which allows most takeover scenarios but avoids e.g&#x2e; two PinchHandlers fighting over the same touchpoints.</p>
</div></div><!-- @@@grabPermissions -->
<br/>
<!-- $$$longPressThreshold -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="longPressThreshold-prop">
<td class="tblQmlPropNode"><p>
<a name="longPressThreshold-prop"></a><span class="name">longPressThreshold</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The time in seconds that an event point must be pressed in order to trigger a long press gesture and emit the <a href="qml-qtquick-taphandler.html#longPressed-signal">longPressed()</a> signal. If the point is released before this time limit, a tap can be detected if the <a href="qml-qtquick-taphandler.html#gesturePolicy-prop">gesturePolicy</a> constraint is satisfied. The default value is <a href="../qtgui/qstylehints.html#mousePressAndHoldInterval-prop">QStyleHints::mousePressAndHoldInterval()</a> converted to seconds.</p>
</div></div><!-- @@@longPressThreshold -->
<br/>
<!-- $$$margin -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="margin-prop">
<td class="tblQmlPropNode"><p>
<a name="margin-prop"></a><span class="name">margin</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The margin beyond the bounds of the <a href="qml-qtquick-taphandler.html#parent-prop">parent</a> item within which an event point can activate this handler. For example, on a <a href="qml-qtquick-pinchhandler.html">PinchHandler</a> where the <a href="qml-qtquick-taphandler.html#target-prop">target</a> is also the <code>parent</code>, it's useful to set this to a distance at least half the width of a typical user's finger, so that if the <code>parent</code> has been scaled down to a very small size, the pinch gesture is still possible. Or, if a <a href="qml-qtquick-taphandler.html">TapHandler</a>-based button is placed near the screen edge, it can be used to comply with Fitts's Law: react to mouse clicks at the screen edge even though the button is visually spaced away from the edge by a few pixels.</p>
<p>The default value is 0.</p>
<p class="centerAlign"><img src="images/pointerHandlerMargin.png" alt="" /></p></div></div><!-- @@@margin -->
<br/>
<!-- $$$parent -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="parent-prop">
<td class="tblQmlPropNode"><p>
<a name="parent-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">parent</span> : <span class="type"><a href="qml-qtquick-item.html">Item</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The <a href="qml-qtquick-item.html">Item</a> which is the scope of the handler; the Item in which it was declared. The handler will handle events on behalf of this Item, which means a pointer event is relevant if at least one of its event points occurs within the Item's interior. Initially <a href="qml-qtquick-taphandler.html#target-prop">target()</a> is the same, but it can be reassigned.</p>
<p><b>请参考 </b><a href="qml-qtquick-taphandler.html#target-prop">target</a> 和 <a href="../qtcore/qobject.html#parent">QObject::parent()</a>。</p>
</div></div><!-- @@@parent -->
<br/>
<!-- $$$point -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="point-prop">
<td class="tblQmlPropNode"><p>
<a name="point-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">point</span> : <span class="type"><a href="qml-qtquick-handlerpoint.html">HandlerPoint</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The event point currently being handled. When no point is currently being handled, this object is reset to default values (all coordinates are 0).</p>
</div></div><!-- @@@point -->
<br/>
<!-- $$$pressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="pressed-prop">
<td class="tblQmlPropNode"><p>
<a name="pressed-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">pressed</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Holds true whenever the mouse or touch point is pressed, and any movement since the press is compliant with the current <a href="qml-qtquick-taphandler.html#gesturePolicy-prop">gesturePolicy</a>. When the event point is released or the policy is violated, <i>pressed</i> will change to false.</p>
</div></div><!-- @@@pressed -->
<br/>
<!-- $$$tapCount -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="tapCount-prop">
<td class="tblQmlPropNode"><p>
<a name="tapCount-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">tapCount</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The number of taps which have occurred within the time and space constraints to be considered a single gesture. For example, to detect a triple-tap, you can write:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
      <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">30</span>
      signal <span class="type">tripleTap</span>
      <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
          <span class="name">acceptedButtons</span>: <span class="name">Qt</span>.<span class="name">AllButtons</span>
          <span class="name">onTapped</span>: <span class="keyword">if</span> (<span class="name">tapCount</span> <span class="operator">==</span> <span class="number">3</span>) <span class="name">tripleTap</span>()
      }
  }

</pre>
</div></div><!-- @@@tapCount -->
<br/>
<!-- $$$target -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="target-prop">
<td class="tblQmlPropNode"><p>
<a name="target-prop"></a><span class="name">target</span> : <span class="type"><a href="qml-qtquick-item.html">Item</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The Item which this handler will manipulate.</p>
<p>By default, it is the same as the <a href="qml-qtquick-taphandler.html#parent-prop">parent</a>, the Item within which the handler is declared. However, it can sometimes be useful to set the target to a different Item, in order to handle events within one item but manipulate another; or to <code>null</code>, to disable the default behavior and do something else instead.</p>
</div></div><!-- @@@target -->
<br/>
<!-- $$$timeHeld -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="timeHeld-prop">
<td class="tblQmlPropNode"><p>
<a name="timeHeld-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">timeHeld</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The amount of time in seconds that a pressed point has been held, without moving beyond the drag threshold. It will be updated at least once per frame rendered, which enables rendering an animation showing the progress towards an action which will be triggered by a long-press. It is also possible to trigger one of a series of actions depending on how long the press is held.</p>
<p>A value of less than zero means no point is being held within this handler's <a href="qml-qtquick-item.html">Item</a>.</p>
</div></div><!-- @@@timeHeld -->
<br/>
<h2>Signal Documentation</h2>
<!-- $$$canceled -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="canceled-signal">
<td class="tblQmlFuncNode"><p>
<a name="canceled-signal"></a><span class="name">canceled</span>(<span class="type"><a href="qml-qtquick-eventpoint.html">EventPoint</a></span> <i>point</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this handler has already grabbed the given <i>point</i>, this signal is emitted when the grab is stolen by a different Pointer Handler or Item.</p>
</div></div><!-- @@@canceled -->
<br/>
<!-- $$$doubleTapped -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="doubleTapped-signal">
<td class="tblQmlFuncNode"><p>
<a name="doubleTapped-signal"></a><span class="name">doubleTapped</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the <code>parent</code> Item is tapped twice within a short span of time (<a href="../qtgui/qstylehints.html#mouseDoubleClickInterval-prop">QStyleHints::mouseDoubleClickInterval</a>) and distance (<a href="../qtgui/qplatformtheme.html#ThemeHint-enum">QPlatformTheme::MouseDoubleClickDistance</a> or <a href="../qtgui/qplatformtheme.html#ThemeHint-enum">QPlatformTheme::TouchDoubleTapDistance</a>). This signal always occurs after <a href="qml-qtquick-taphandler.html#singleTapped-signal">singleTapped</a>, <a href="qml-qtquick-taphandler.html#tapped-signal">tapped</a>, and <a href="qml-qtquick-taphandler.html#tapCountChanged-signal">tapCountChanged</a>.</p>
<p>This signal was introduced in  Qt 5.11.</p>
</div></div><!-- @@@doubleTapped -->
<br/>
<!-- $$$grabChanged -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="grabChanged-signal">
<td class="tblQmlFuncNode"><p>
<a name="grabChanged-signal"></a><span class="name">grabChanged</span>(<span class="type">GrabTransition</span> <i>transition</i>,  <span class="type"><a href="qml-qtquick-eventpoint.html">EventPoint</a></span> <i>point</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the grab has changed in some way which is relevant to this handler.</p>
<p>The <i>transition</i> (verb) tells what happened. The <i>point</i> (object) is the point that was grabbed or ungrabbed.</p>
</div></div><!-- @@@grabChanged -->
<br/>
<!-- $$$longPressed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="longPressed-signal">
<td class="tblQmlFuncNode"><p>
<a name="longPressed-signal"></a><span class="name">longPressed</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the <code>parent</code> Item is pressed and held for a time period greater than <a href="qml-qtquick-taphandler.html#longPressThreshold-prop">longPressThreshold</a>. That is, if you press and hold a touchpoint or button, while any movement does not exceed the drag threshold, then the <code>longPressed</code> signal will be emitted at the time that <a href="qml-qtquick-taphandler.html#timeHeld-prop">timeHeld</a> exceeds <a href="qml-qtquick-taphandler.html#longPressThreshold-prop">longPressThreshold</a>.</p>
</div></div><!-- @@@longPressed -->
<br/>
<!-- $$$singleTapped -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="singleTapped-signal">
<td class="tblQmlFuncNode"><p>
<a name="singleTapped-signal"></a><span class="name">singleTapped</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the <code>parent</code> Item is tapped once. After an amount of time greater than <a href="../qtgui/qstylehints.html#mouseDoubleClickInterval-prop">QStyleHints::mouseDoubleClickInterval</a>, it can be tapped again; but if the time until the next tap is less, <a href="qml-qtquick-taphandler.html#tapCount-prop">tapCount</a> will increase.</p>
<p>This signal was introduced in  Qt 5.11.</p>
</div></div><!-- @@@singleTapped -->
<br/>
<!-- $$$tapCountChanged -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="tapCountChanged-signal">
<td class="tblQmlFuncNode"><p>
<a name="tapCountChanged-signal"></a><span class="name">tapCountChanged</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the <code>parent</code> Item is tapped once or more (within a specified time and distance span) and when the present <code>tapCount</code> differs from the previous <code>tapCount</code>.</p>
</div></div><!-- @@@tapCountChanged -->
<br/>
<!-- $$$tapped -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="tapped-signal">
<td class="tblQmlFuncNode"><p>
<a name="tapped-signal"></a><span class="name">tapped</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted each time the <code>parent</code> Item is tapped.</p>
<p>That is, if you press and release a touchpoint or button within a time period less than <a href="qml-qtquick-taphandler.html#longPressThreshold-prop">longPressThreshold</a>, while any movement does not exceed the drag threshold, then the <code>tapped</code> signal will be emitted at the time of release.</p>
</div></div><!-- @@@tapped -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
